package com.kgcx.organization.controller;

import com.kgcx.common.bean.RequestData;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.organization.domain.Station;
import com.kgcx.organization.domain.StationExit;
import com.kgcx.organization.domain.StationParking;
import com.kgcx.organization.service.StationExitService;
import com.kgcx.organization.service.StationParkingService;
import com.kgcx.organization.service.StationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "站务接口", tags = "站务接口")
@RestController
@RequestMapping("station")
public class StationController extends BaseController {
    @Autowired
    private StationService stationService;

    @Autowired
    private StationExitService stationExitService;

    @Autowired
    private StationParkingService stationParkingService;

    @ApiOperation(value = "查询站务", httpMethod = "GET", notes = "这是用来查询站务的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "站务ID", required = true, paramType = "query", dataType = "String", dataTypeClass = Long.class),
    })
    @GetMapping("getStation")
    public ReturnData<Station> getStation() {
        RequestData requestData = this.getRequestData();
        Station station = stationService.getStation(requestData.getLong("kid"));
        return new ReturnData<>(station);
    }

    @ApiOperation(value = "查询站务", httpMethod = "GET", notes = "这是用来查询站务的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName", value = "城市", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "cityId", value = "城市id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getStationList")
    public ReturnData<List<Station>> getStationList() {
        RequestData requestData = this.getRequestData();
        List<Station> stationList = stationService.getStationList(requestData);
        return new ReturnData<>(stationList);
    }

    @ApiOperation(value = "新增站务", httpMethod = "POST", notes = "这是用来新增站务的接口")
    @PostMapping("addStation")
    public ReturnData addStation(@RequestBody Station station) {
        stationService.addStation(station);
        return new ReturnData();
    }

    @ApiOperation(value = "修改站务", httpMethod = "POST", notes = "这是用来修改站务的接口")
    @PostMapping("updateStation")
    public ReturnData updateStation(@RequestBody Station station) {
        stationService.updateStation(station);
        return new ReturnData();
    }

    @ApiOperation(value = "删除站务", httpMethod = "POST", notes = "这是用来删除站务的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeStation")
    public ReturnData removeStation(@RequestParam Long kid) {
        stationService.removeStation(kid);
        return new ReturnData();
    }

    @ApiOperation(value = "查询站务出口", httpMethod = "GET", notes = "这是用来查询站务出口的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cityName", value = "城市", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "cityId", value = "城市id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "stationId", value = "站务id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getStationExitList")
    public ReturnData<List<StationExit>> getStationExitList() {
        RequestData requestData = this.getRequestData();
        List<StationExit> stationExitList = stationExitService.getStationExitList(requestData);
        return new ReturnData<>(stationExitList);
    }


    @ApiOperation(value = "新增站务出口", httpMethod = "POST", notes = "这是用来新增站务出口的接口")
    @PostMapping("addStationExit")
    public ReturnData addStationExit(@RequestBody StationExit stationExit) {
        stationExitService.addStationExit(stationExit);
        return new ReturnData();
    }

    @ApiOperation(value = "修改站务出口", httpMethod = "POST", notes = "这是用来修改站务出口的接口")
    @PostMapping("updateStationExit")
    public ReturnData updateStationExit(@RequestBody StationExit stationExit) {
        stationExitService.updateStationExit(stationExit);
        return new ReturnData();
    }

    @ApiOperation(value = "删除站务出口", httpMethod = "POST", notes = "这是用来删除站务出口的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeStationExit")
    public ReturnData removeStationExit(@RequestParam Long kid) {
        stationExitService.removeStationExit(kid);
        return new ReturnData();
    }

    @ApiOperation(value = "查询站务出口", httpMethod = "GET", notes = "这是用来查询站务出口的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationId", value = "站务id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "stationExitId", value = "站务出口id", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("getStationParkingList")
    public ReturnData<List<StationParking>> getStationParkingList() {
        RequestData requestData = this.getRequestData();
        List<StationParking> stationParkingList = stationParkingService.getStationParkingList(requestData);
        return new ReturnData<>(stationParkingList);
    }


    @ApiOperation(value = "新增站务泊车位", httpMethod = "POST", notes = "这是用来新增站务泊车位的接口")
    @PostMapping("addStationParking")
    public ReturnData addStation(@RequestBody StationParking stationParking) {
        stationParkingService.addStationParking(stationParking);
        return new ReturnData();
    }

    @ApiOperation(value = "修改站务泊车位", httpMethod = "POST", notes = "这是用来修改站务泊车位的接口")
    @PostMapping("updateStationParking")
    public ReturnData updateStationParking(@RequestBody StationParking stationParking) {
        stationParkingService.updateStationParking(stationParking);
        return new ReturnData();
    }

    @ApiOperation(value = "删除站务泊车位", httpMethod = "POST", notes = "这是用来删除站务泊车位的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "用户ID", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class)
    })
    @PostMapping("removeStationParking")
    public ReturnData removeStationParking(@RequestParam Long kid) {
        stationParkingService.removeStationParking(kid);
        return new ReturnData();
    }

}
